CentOS 9 安装 Nginx 模块 `subs

您所在的位置:网站首页 centos 65 u盘安装 CentOS 9 安装 Nginx 模块 `subs

CentOS 9 安装 Nginx 模块 `subs

2023-05-30 20:47| 来源: 网络整理| 查看: 265

sub_filter 和 subs_filter 区别 sub_filter( 0.7.24):替换响应体(Response Body)中的文本,只能设置一组替换。 subs_filter:替换响应体(Response Body)和响应头(Response Headers)中的文本,可以设置多组替换。

sub_filter 使用案例:

http { server { listen 80; server_name example.com; location / { sub_filter 'old-text' 'new-text'; sub_filter_once off; proxy_pass http://backend; } } }

subs_filter 使用案例:

http { server { listen 80; server_name example.com; location / { subs_filter 'old-text-1' 'new-text-1'; subs_filter 'old-text-2' 'new-text-2'; proxy_pass http://backend; } subs_filter_types text/*; subs_filter_types application/json; } } 安装方式 方法 1:命令行安装

CentOS 常规安装的 Nginx 中并不包含 subs_filter,需要额外安装 nginx-mod-http-sub 添加对其功能的支持。

1. 安装模块

sudo dnf install nginx-mod-http-sub

2. 加载模块

load_module modules/ngx_http_subs_filter_module.so;

CentOS 系统下只有 Nginx Plus 才能这么操作,否则需要重新编译 Nginx。Debian 系统已经直接安装了此模块。

方法 2:源码编译

1. 下载模块

git clone git://github.com/yaoweibin/ngx_http_substitutions_filter_module.git

2. 编译

./configure --add-module=/path/to/module

版权声明

本博客所有的原创文章,作者皆保留版权。转载必须包含本声明,保持本文完整,并以超链接形式注明作者后除和本文原始地址:blog.mazey.net/3525.html

(完)



【本文地址】


今日新闻


推荐新闻


    CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3